var e = {}; 

e.fired = false;

e.geode = {};
e.geode.head = '<div class="gl">geodelab</div>'+
               '<div class="nav">'+
               '<a class="nav-link" href="/">HOME</a>'+
               '<a class="nav-link" href="/projects">PROJECTS</a>'+
               '<a class="nav-link" href="/members">MEMBERS</a>'+
               '<a class="nav-link" href="/connect">CONNECT</a>'+
               '<a class="nav-link" href="/downloads">DOWNLOADS</a>'+
               '</div>';

e._f= '&copy; 2012 Geode Software Lab. All rights reserved.';

e.a = function () {
  var h, c;
  h = e.geode.head;

  document.getElementById('head').innerHTML = h;
  document.getElementById('foot').innerHTML = e._f;
  document.getElementById('content').innerHTML = e.b();
  e.fired = true;
};

e.b = function () {
  var p = location.pathname, x = new XMLHttpRequest(), s = new Showdown.converter;
  P = p.split('/');
  if(P[P.length - 1] === "") { p+="index.html"; }
  x.open('GET', p+'.md', false);
  x.send();
  return s.makeHtml(x.response);
};

e.c = function () {
 // if(!e.fired) {
    //console.log('[ APP ] e.a fire timeout.');
    e.a();
 // } else {
    //console.log('[ APP ] e.a fired already.');
 // }
};

e.d = function () {
  if(document.getElementById('content').innerHTML.length < 6) {
    location.reload();
  }
};

window.onload = e.a;

setTimeout(e.c, 300);
setTimeout(e.d, 1000);
